package com.ruoyi.yuan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yuan.domain.Cluster;
import com.ruoyi.yuan.service.IClusterService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 星系团信息Controller
 * 
 * @author guifeng
 * @date 2022-08-21
 */
@Api("星系团信息")
@RestController
@RequestMapping("/yuan/cluster")
public class ClusterController extends BaseController
{
    @Autowired
    private IClusterService clusterService;

    /**
     * 查询星系团信息列表
     */
    @ApiOperation("查询星系团信息列表")
    @PreAuthorize("@ss.hasPermi('yuan:cluster:list')")
    @GetMapping("/list")
    public AjaxResult list(Cluster cluster)
    {
        List<Cluster> list = clusterService.selectClusterList(cluster);
        return AjaxResult.success(list);
    }

    /**
     * 导出星系团信息列表
     */
    @ApiOperation("导出星系团信息列表")
    @PreAuthorize("@ss.hasPermi('yuan:cluster:export')")
    @Log(title = "星系团信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Cluster cluster)
    {
        List<Cluster> list = clusterService.selectClusterList(cluster);
        ExcelUtil<Cluster> util = new ExcelUtil<Cluster>(Cluster.class);
        util.exportExcel(response, list, "星系团信息数据");
    }

    /**
     * 获取星系团信息详细信息
     */
    @ApiOperation("获取星系团信息详细信息")
    @PreAuthorize("@ss.hasPermi('yuan:cluster:query')")
    @GetMapping(value = "/{clusterId}")
    public AjaxResult getInfo(@PathVariable("clusterId") Long clusterId)
    {
        return AjaxResult.success(clusterService.selectClusterByClusterId(clusterId));
    }

    /**
     * 新增星系团信息
     */
    @ApiOperation("新增星系团信息")
    @PreAuthorize("@ss.hasPermi('yuan:cluster:add')")
    @Log(title = "星系团信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Cluster cluster)
    {
        return toAjax(clusterService.insertCluster(cluster));
    }

    /**
     * 修改星系团信息
     */
    @ApiOperation("修改星系团信息")
    @PreAuthorize("@ss.hasPermi('yuan:cluster:edit')")
    @Log(title = "星系团信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Cluster cluster)
    {
        return toAjax(clusterService.updateCluster(cluster));
    }

    /**
     * 删除星系团信息
     */
    @ApiOperation("删除星系团信息")
    @PreAuthorize("@ss.hasPermi('yuan:cluster:remove')")
    @Log(title = "星系团信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{clusterIds}")
    public AjaxResult remove(@PathVariable Long[] clusterIds)
    {
        return toAjax(clusterService.deleteClusterByClusterIds(clusterIds));
    }
}
